<!--
  ~ This program is part of the OpenLMIS logistics management information system platform software.
  ~ Copyright © 2013 VillageReach
  ~
  ~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  ~  
  ~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
  ~ You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
  -->
<ng-include src="'/public/pages/logistics/distribution/partials/record-facility-data.html'"></ng-include>

<div class="clearfix facility-container"
     ng-init="facilityData = distribution.facilityDistributions[selectedFacilityId]">
  <ng-include src="'/public/pages/logistics/distribution/partials/record-facility-menu.html'"></ng-include>
  <div class="facility-info">
    <div class="refrigerator-container" disable-form="{{facilityData.isDisabled('refrigerators')}}">
      <h3>
        <span id="refrigeratorsLabel" openlmis-message="label.refrigerators"></span>
        <input type="button" class="btn btn-primary pull-right" id="addNew" ng-click="showRefrigeratorModal()"
               openlmis-message="button.add.new"/>
      </h3>

      <div class="alert alert-info" id="noRefrigerators"
           ng-hide="facilityData.refrigerators.readings.length">
        <span openlmis-message="message.no.refrigerators.added"></span>
      </div>

      <div
          ng-show="facilityData.refrigerators.readings.length">
        <div class="list-header-container">
          <div class="list-header row-fluid">
            <div class="span1"></div>
            <div class="span3" openlmis-message="label.refrigerator.serial.number"></div>
            <div class="span2" openlmis-message="label.refrigerator.brand"></div>
            <div class="span3" openlmis-message="label.refrigerator.model"></div>
            <div class="span3"></div>
          </div>
        </div>
        <div class="list-container">
          <div class="list-row" ng-class="{isEditable: edit[refrigeratorReading.refrigerator.serialNumber]}"
               ng-repeat="refrigeratorReading in facilityData.refrigerators.readings">
            <ng-include
                src="'/public/pages/logistics/distribution/partials/refrigerator-reading.html'"></ng-include>
          </div>
        </div>

      </div>

      <div id="addRefrigeratorModal" modal="addRefrigeratorModal" options="{ backdrop: 'static', escape: false}">
        <div class="modal-header">
          <h3 openlmis-message="label.new.refrigerator"></h3>
        </div>

        <div class="modal-body">
          <div class="row-fluid">
            <div class="span12">
              <label for="manufacturerSerialNumber">
                <span openlmis-message="label.refrigerator.serial.number"></span>
                <span class="label-required">*</span>
              </label>
              <input type="text" id="manufacturerSerialNumber" maxlength="30"
                     ng-model="newRefrigeratorReading.refrigerator.serialNumber"/>

              <div id="duplicateSerialNumberError" ng-show="isDuplicateSerialNumber" class="rnr-form-error"
                   openlmis-message="error.duplicate.serial.number"></div>
            </div>
          </div>
          <div class="row-fluid">
            <div class="span12">
              <label for="brand" openlmis-message="label.refrigerator.brand">
              </label>
              <input type="text" id="brand" ng-model="newRefrigeratorReading.refrigerator.brand"
                     maxlength="20"/>
            </div>
          </div>

          <div class="row-fluid">
            <div class="span12">
              <label for="model" openlmis-message="label.refrigerator.model">
              </label>
              <input type="text" id="model" ng-model="newRefrigeratorReading.refrigerator.model"
                     maxlength="20"/>
            </div>
          </div>
        </div>

        <div class="modal-footer">
          <input type="button" id="done-button" class="btn btn-primary" ng-click="addRefrigeratorToStore()"
                 openlmis-message="button.done"
                 ng-disabled="!newRefrigeratorReading.refrigerator.serialNumber"/>
          <input id="button-cancel" type="button" class="btn btn-cancel"
                 ng-click="addRefrigeratorModal = false;"
                 openlmis-message="button.cancel"/>
        </div>

      </div>
    </div>
  </div>
</div>

</div>

